public class SubjectProxy extends AbstractSubject{

//代理服务，先注入真实实现类
    private AbstractSubject subjectReal;


    public SubjectProxy(AbstractSubject subjectReal){
        this.subjectReal=subjectReal;
    }


    @Override
    public String doSearch(String userId, String keyword) {
        subjectReal.doSearch(userId,keyword);  // 搜索信息
        validate(userId);    //验证信息
        log(userId);         //记入日志
        return null;
    }
    public boolean validate(String userId){  //验证模块
        System.out.println("验证用户ID:"+userId);

        System.out.println("密码正确");
        return true;
    }
    public void log(String userId){     //记录日志
        System.out.println("搜索用户结果:"+userId+"-----成功-----记入日志");
    }

}
